package com.glsc.ngateway.platform.service.itflow.flowstrategy.equipmentModify.taskPostHandler;

import com.glsc.ngateway.common.api.flowable.dto.task.doTaskParam.equipment.EquipmentPassParamDto;
import com.glsc.ngateway.common.api.flowable.dto.task.formData.equipment.EquipmentModifyTaskFormDataDto;
import com.glsc.ngateway.common.api.flowable.dto.task.formData.equipment.domainDto.FlowFormEquipmentModifyDto;
import com.glsc.ngateway.platform.service.itflow.flowstrategy.equipmentModify.EquipmentModifyFlowStrategy;
import com.glsc.ngateway.common.base.enums.itflow.ITFlowTaskEnum;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * 流程发起
 * @author xuchang
 */
@Component
public class EMStep1BeginTaskPostHandlerAudit implements IEquipmentModifyTaskPostHandlerAudit {

    @Resource
    private EquipmentModifyFlowStrategy modifyFlowStrategy;
    /**
     * 退回至起点重新发起时，走审批方法
     */
    @Override
    public void passAfterHandle(@NotNull EquipmentPassParamDto<FlowFormEquipmentModifyDto, EquipmentModifyTaskFormDataDto> param, String operator) throws Exception {
        modifyFlowStrategy.saveOrUpdateForm(param.getFlowableFormData(), operator);
    }

    @Override
    public String getTaskDefinitionKey() {
        return ITFlowTaskEnum.MODIFY_FLOW_BEGIN_TASK.getTaskKey();
    }
}
